package www.rlicker.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import www.rlicker.dao.ISysUserDao;
import www.rlicker.model.SysUser;
import www.rlicker.mybatis.Criteria;
import www.rlicker.service.ISysUserService;
import www.rlicker.utils.MessageConstant;
import www.rlicker.utils.TranslateToMap;

@Service
public class SysUserServiceImpl implements ISysUserService{


	/**
	 * 
	 * 分页查询
	 * 
	 **/
	public List<Map<String, Object>>  queryPage (Criteria<SysUser> param){
		List<SysUser> list = sysUserRepository.queryPage(param);
		List<Map<String,Object>> map = TranslateToMap.convertListBean2ListMap(list,SysUser.class);
	return map;  }

	/**
	 * 
	 * 分页总数查询
	 * 
	 **/
	public Integer queryPageCount (Criteria<SysUser> param){
		return (Integer) sysUserRepository.queryPageCount(param);
	}

	/**
	 * 
	 * 查询（根据主键ID查询）
	 * 
	 **/
	public SysUser  queryEntity (String id ){
		return sysUserRepository.queryEntity(id);
	}

	/**
	 * 
	 * 删除（根据主键ID删除）
	 * 
	 **/
	public String deleteById (String id ){
		int result = sysUserRepository.deleteById(id);
			if ( result != 1) {
					return MessageConstant.USER_TYPE_3;
			}
		return null;
	}

	/**
	 * 
	 * 添加 （匹配有值的字段）
	 * 
	 **/
	public String insert(SysUser record ){
		int result = sysUserRepository.insert(record);
			if ( result != 1) { 
					return MessageConstant.USER_TYPE_4;
			}
		return null;
	}

	/**
	 * 
	 *  修改（匹配有值的字段）
	 * 
	 **/
	public String update (Criteria<SysUser> param){
		int result = sysUserRepository.update(param);
			if ( result != 1) { 
					return MessageConstant.USER_TYPE_5;
			}
		return null;
	}

	@Resource
	private ISysUserDao sysUserRepository;

}